from rest_framework import serializers
from order import models

class OrderSerializer(serializers.ModelSerializer):
    addresslist=serializers.SerializerMethodField(read_only=True)
    def get_addresslist(self,obj):
        return [{"name":obj.address.name,"phone":obj.address.phone,"Shaddress":obj.address.Shaddress,"address":obj.address.address}]
    class Meta:
        model=models.OrderModel
        fields='__all__'
class AddressSerializer(serializers.ModelSerializer):
    class Meta:
        model=models.AddressModel
        fields='__all__'